package com.three.service.impl;

import com.baor.baseUtil.R;
import com.three.dao.AttendanceDao;
import com.three.domain.Attendance;
import com.three.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(rollbackFor = Exception.class)
public class AttendanceServiceImpl implements AttendanceService {
    @Autowired
    private AttendanceDao attendanceDao;

    @Override
    public R attendanceList(Integer id, Integer pageIndex, Integer pageSize,String date) {
        pageIndex = (pageIndex - 1) * pageSize;
        double pageCount = attendanceDao.PageCount(id,date);
        System.out.println(pageCount);
        pageCount = Math.ceil(pageCount / pageSize);
        List<Attendance> attendanceList = attendanceDao.attendanceList(id,pageIndex, pageSize,date);
        Map<String, Object> map = new HashMap<>();
        map.put("pageCount", pageCount);
        map.put("attendanceList", attendanceList);
        return R.ok(map);
    }


}
